// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI, { TabPane } from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/iconfont.css'
import VueQuillEditor from 'vue-quill-editor'

import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.use(VueQuillEditor, /* { default global options } */)

// 使用钩子函数对路由进行权限跳转  7个 全局3个  组件内3个
router.beforeEach((to,from,next)=>{
  document.title=`${to.meta.title}|HappyMmall后端管理系统`;
  const role =localStorage.getItem("admin");
  if(!role && to.path !== '/login'){
    next("/login")
  }else if(to.meta.permission){
    role === 'admin' ? next():next('/403')
  }else{
    if(navigator.userAgent.indexOf('MISE')>-1 &&to.path ==='/edit'){//富文本编辑器 判断IE10及以下浏览器不能进入
        alert("富文本编辑器组件不兼容IE10以下浏览器")
    }else{
      next()
    }
    
  }
  
})


/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
